"""
URL configuration for djangoProject project.

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/5.0/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, re_path , include
from . import views


urlpatterns = [
    path('admin/', admin.site.urls),
    path('page/2003/' , views.page_2003_view),
    #http://127.0.0.1:8000/
    path('' , views.index_view),
    #http://127.0.0.1:8000/page/1
    path('page/1' , views.page1_view),
    #http://127.0.0.1:8000/page/2
    path('page/2' , views.page2_view),
    #http://127.0.0.1:8000/page/3-100 ， 其实所有的web其实都是差不多的
    path('page/<int:pg>' , views.pagen_view),
    re_path(r'^(?P<num1>\d{1,2})/(?P<oper>\w+)/(?P<num2>\d{1,2})$', views.calculator_pat),
    # re_path(r"bio/(?P<username>\w+)/$" , views.bio)
    #定义计算器路由功能
    path('<int:num1>/<str:oper>/<int:num2>' , views.calculator),

    #下面两个都能得到相同的结果，因为是按照关键字参数名称传递的
    #http://127.0.0.1:8000/birthday/年4/月2/日/2
    re_path(r"^birthday/(?P<y>\d{4})/(?P<m>\d{1,2})/(?P<d>\d{1,2})$" , views.birthday_view),
    #http://127.0.0.1:8000/birthday/年4/月2/日/2
    re_path(r"^birthday/(?P<m>\d{1,2})/(?P<d>\d{1,2})/(?P<y>\d{4})$" , views.birthday_view),

    path('test_request' , views.test_request),

    path('test_get_post' , views.test_get_post),

    #计算器
    path('cal_two' , views.cal_two),

    #模版测试
    path('test_html' , views.test_html),

    #模版传递变量测试
    path('test_html_param' , views.test_html_param),

    #模版语法
    path('test_if_for' , views.test_if_for),

    #简易计算器
    path('mycal' , views.mycal),

    path('base_index' , views.base_view , name='base_index'),
    path('music_index' , views.music_view),
    path('sport_index' , views.sport_view),

    path('test_url' , views.test_url),
    path('test_url_result/<int:age>' , views.test_url_result,name='tr'),

    #静态资源
    path('test_static' , views.test_static),

    #------使用分布式路由------
    #音乐模块
    path('music/' , include('music.urls')),
    #运动模块
    path('sport/', include('sport.s_urls')),
    # #新闻模块
    path('sport/', include('news.n_urls')),

    #书本模块
    path('book/' , include('bookstore.urls')),

    #游戏模块
    path('game/' , include('bookstore.urls')),

    #小帮菜模块
    path('xbc/' , include("bookstore.urls")),

    #关联映射 一对一
    path('oto/' , include('oto.urls')),

    #关联映射 一对多
    path('otm/' , include('otm.urls')),

    #关系映射 多对多
    path('mtm/' , include('mtm.urls')),

    #cookie和session
    path('cookie_session/' , include('cookie_session.urls'))


]
